package home

type DemoController struct {
	BaseController
}

func NewDemoController() *DemoController {
	return &DemoController{}
}

func (ctrl *DemoController) GetBarDemo() {

	ctrl.OK(map[string]interface{}{
		"legend": map[string]interface{}{
			"data": []interface{}{"直接访问001", "直接访问002"},
		},
		"xAxis": []interface{}{
			map[string]interface{}{
				"data": []interface{}{
					"旅游行业01",
					"教育培训02",
					"游戏行业03",
					"医疗行业04",
					"电商行业05",
					"社交行业06",
					"金融行业07",
				},
			},
		},
		"series": []interface{}{
			map[string]interface{}{
				"name": "直接访问001",
				"data": []interface{}{200, 300, 300, 900, 1500, 1200, 600},
			},
			map[string]interface{}{
				"name": "直接访问002",
				"data": []interface{}{200, 300, 300, 900, 1500, 1200, 600},
			},
		},
	})
	return

}

func (ctrl *DemoController) GetProvinceDemo() {

	ctrl.OK([]interface{}{
		map[string]interface{}{
			"province_id":   11,
			"province_name": "吉林省",
		},
		map[string]interface{}{
			"province_id":   12,
			"province_name": "黑龙江省",
		},
		map[string]interface{}{
			"province_id":   13,
			"province_name": "辽宁省",
		},
	})

}
func (ctrl *DemoController) GetCityDemo() {

	provinceID, _ := ctrl.GetUint64("province_id", 0)
	if provinceID == 11 {
		ctrl.OK([]interface{}{
			map[string]interface{}{
				"city_id":   1101,
				"city_name": "长春市",
			},
			map[string]interface{}{
				"city_id":   1102,
				"city_name": "吉林市",
			},
			map[string]interface{}{
				"city_id":   1103,
				"city_name": "松原市",
			},
		})
		return
	}

	ctrl.OK([]interface{}{})
	return

}
func (ctrl *DemoController) GetRadarDemo() {

	ctrl.OK(map[string]interface{}{
		"legend": map[string]interface{}{
			"data": []interface{}{"A", "B"},
		},
		"radar": map[string]interface{}{
			"indicator": []interface{}{
				map[string]interface{}{"name": "AA1", "max": 45451},
				map[string]interface{}{"name": "BB1", "max": 45451},
				map[string]interface{}{"name": "CC1", "max": 45451},
				map[string]interface{}{"name": "DD1", "max": 38000},
				map[string]interface{}{"name": "EE1", "max": 45451},
				map[string]interface{}{"name": "FF1", "max": 25000},
			},
		},
		"series": []interface{}{
			map[string]interface{}{
				"data": []interface{}{
					map[string]interface{}{"name": "A", "value": []interface{}{4200, 3000, 20000, 35000, 50000, 18000}},
					map[string]interface{}{"name": "B", "value": []interface{}{420, 300, 2000, 3500, 5000, 18000}},
				},
			},
		},
	})
	return

}
func (ctrl *DemoController) GetTeaTitleDemo() {

	ctrl.OK([]interface{}{

		map[string]interface{}{
			"id":    1,
			"title": "高级",
		},
		map[string]interface{}{
			"id":    2,
			"title": "中级",
		},
		map[string]interface{}{
			"id":    3,
			"title": "初级",
		},
	})

	return

}

func (ctrl *DemoController) GetMapDemo() {

	//	{
	//	legend:{
	//	data:["全国数据"]
	//},
	//series:[
	//{
	//name:"全国数据",
	//data:[
	//{ name:"南海诸岛",value:1111,},
	//{ name: "辽宁", value: 2222},
	//{ name: "黑龙江", value: 33333},
	//{ name: "吉林", value: 444},
	//]
	//}
	//]
	//
	//}
	//
	//}
	ctrl.OK(map[string]interface{}{

		"legend": map[string]interface{}{
			"data": []interface{}{
				"全国数据",
			},
		},

		"series": []interface{}{
			map[string]interface{}{
				"name": "全国数据",
				"data": []interface{}{
					map[string]interface{}{
						"name":  "辽宁",
						"value": 258,
					},
					map[string]interface{}{
						"name":  "吉林",
						"value": 258,
					},
					map[string]interface{}{
						"name":  "黑龙江",
						"value": 258,
					},
				},
			},
		},
	})

	return

}

func (ctrl *DemoController) Chart() {
	ctrl.View()
	return
}
func (ctrl *DemoController) Index() {
	ctrl.View()
	return
}

func (ctrl *DemoController) GetBar2Demo() {

	ctrl.OK(map[string]interface{}{
		"unit": "%",
		"data": []interface{}{
			map[string]interface{}{
				"name":   "A",
				"value":  13,
				"weight": 15,
			},
			map[string]interface{}{
				"name":   "B",
				"value":  63,
				"weight": 15,
			},
			map[string]interface{}{
				"name":   "C",
				"value":  65,
				"weight": 50,
			},
			map[string]interface{}{
				"name":   "D",
				"value":  40,
				"weight": 15,
			},
			map[string]interface{}{
				"name":   "E",
				"value":  123,
				"weight": 30,
			},
			map[string]interface{}{
				"name":   "F",
				"value":  13,
				"weight": 40,
			},
			map[string]interface{}{
				"name":   "G",
				"value":  123,
				"weight": 20,
			},
			map[string]interface{}{
				"name":   "H",
				"value":  13,
				"weight": 10,
			},
		},
	})
	return

}

func (ctrl *DemoController) GetPieDemo() {

	ctrl.OK(map[string]interface{}{
		"legend": map[string]interface{}{
			"data": []interface{}{"直接访问", "邮件营销", "联盟广告", "视频广告", "搜索引擎"},
		},
		"series": []interface{}{
			map[string]interface{}{
				"name": "访问来源",
				"data": []interface{}{
					map[string]interface{}{
						"value": 223,
						"name":  "直接访问",
					},
					map[string]interface{}{
						"value": 16,
						"name":  "邮件营销",
					},
					map[string]interface{}{
						"value": 67,
						"name":  "联盟广告",
					},
					map[string]interface{}{
						"value": 33,
						"name":  "视频广告",
					},
					map[string]interface{}{
						"value": 22,
						"name":  "搜索引擎",
					},
					map[string]interface{}{
						"value": 335,
						"name":  "其它",
					},
				},
			},
		},
	})
	return

}

func (ctrl *DemoController) GetLineDemo() {

	ctrl.OK(map[string]interface{}{
		"legend": map[string]interface{}{
			"data": []interface{}{"直接访问001", "直接访问002"},
		},
		"xAxis": []interface{}{
			map[string]interface{}{
				"data": []interface{}{
					"旅游行业01",
					"教育培训02",
					"游戏行业03",
					"医疗行业04",
					"电商行业05",
					"社交行业06",
					"金融行业07",
				},
			},
		},
		"series": []interface{}{
			map[string]interface{}{
				"name": "直接访问001",
				"data": []interface{}{600, 300, 300, 900, 1500, 1200, 600},
			},
			map[string]interface{}{
				"name": "直接访问002",
				"data": []interface{}{200, 500, 700, 500, 500, 1000, 700},
			},
		},
	})
	return

}

func (ctrl *DemoController) GetAreaDemo() {

	cityID, _ := ctrl.GetUint64("city_id", 0)
	if cityID == 1101 {
		ctrl.OK([]interface{}{
			map[string]interface{}{
				"area_id":   110101,
				"area_name": "南关区",
			},
			map[string]interface{}{
				"area_id":   110102,
				"area_name": "二道区",
			},
		})
		return
	}

	ctrl.OK([]interface{}{})
	return

}
